package com.example.demofdfs.test.obj;

import java.util.Queue;

public class Producer<E> implements Runnable {

	private Queue<E> queue;
	
	public Producer(Queue<E> queue) {
		this.queue = queue;
	}
	
	public void add(E o) {
		synchronized (queue) {
			if (queue.isEmpty()) {
				queue.offer(o);
				queue.notify();
			} else {
				try {
					queue.wait();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}
	}

	@Override
	public void run() {
	}
}
